<div class="tab_item" style="display:block;">
    <div class="ui_table">
        <form>
            <input type="hidden" name="id" value="${entity.id}">
            <input type="hidden" name="agentId" value="${entity.agentId}">

            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td width="100" align="right">设备编号：</td>
                    <td><input type="text" class="text easyui-validatebox" required="true" name="id" readonly
                               maxlength="6"
                               value="${(entity.id)!''}"/></td>
                    <td width="100" align="right">设备名称：</td>
                    <td><input type="text" class="text easyui-validatebox" required="true" name="cabinetName"
                               maxlength="40"
                               value="${(entity.cabinetName)!''}"/></td>
                </tr>
                <tr>
                    <td align="right">IP地址：</td>
                    <td><input type="text" class="text easyui-validatebox" name="ip" value="${(entity.ip)!''}"
                               maxlength="20"/></td>
                    <td align="right">是否启用：</td>
                    <td><input type="checkbox" class="checkbox" name="activeFlag" value="1"
                               <#if (entity.activeFlag)?? && entity.activeFlag == 1>checked</#if>/></td>
                </tr>
                <tr>
                    <td align="right">电源厂商：</td>
                    <td>
                        <select name="powerSupplierId" id="power_supplier_id_${pid}" class="easyui-combobox" required
                                style="width: 182px; height: 30px;" editable="false">
                        <#list powerSupplierList as e>
                            <option value="${e.id}"
                                    <#if (entity.powerSupplierId)?? && e.id == entity.powerSupplierId>selected="selected"</#if>>${(e.supplierName)!''}</option>
                        </#list>
                        </select>
                    </td>
                    <td align="right">柜子厂商：</td>
                    <td>
                        <select name="cabinetSupplierId" id="cabinet_supplier_id_${pid}" class="easyui-combobox"
                                required editable="false"
                                style="width: 182px; height: 30px;">
                        <#list cabinetSupplierList as e>
                            <option value="${e.id}"
                                    <#if (entity.cabinetSupplierId)?? && e.id == entity.cabinetSupplierId>selected="selected"</#if>>${(e.supplierName)!''}</option>
                        </#list>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td align="right">策略：</td>
                    <td>
                        <input name="strategyId" class="easyui-combotree" editable="false"
                               data-options="<#if (entity.agencyId)??&&entity.agencyId!=0>url:'${contextPath}/security/hdw/cabinet_strategy/tree.htm?agentId=${entity.agentId}&agencyId=${entity.agencyId}',method:'get'</#if>"
                               value="${(entity.strategyId)!''}"
                               style="width: 184px; height: 28px;" required="required" id="cabinet_strategy_id_${pid}"
                        />
                    </td>
                    <td align="right">金额分配：</td>
                    <td>
                        <input name="dividePlanId" class="easyui-combotree" editable="false"
                               value="${(entity.dividePlanId)!''}"
                               style="width: 184px; height: 28px;" required="required" id="divite_plan_id_${pid}"
                               data-options="<#if (entity.agencyId)??&&entity.agencyId!=0>url:'${contextPath}/security/hdw/exchange_amount_money_divide/tree.htm?agentId=${entity.agentId}&agencyId=${entity.agencyId}',method:'get'</#if>"/>
                    </td>
                </tr>
                <tr>
                    <td align="right">充电温度区间：</td>
                    <td><input type='number' min="0" max="100" name="rpt" class="text easyui-validatebox"
                               style="width: 60px" required value="${entity.rpt}"/>
                        -<input type='number' min="0" max="100" name="pt" class="text easyui-validatebox"
                                style="width: 60px" required value="${entity.pt}"/>
                    </td>
                    <td align="right">风扇温度区间：</td>
                    <td><input type='number' min="0" max="100" name="fot" class="text easyui-validatebox"
                               style="width: 60px" required value="${entity.fot}"/>
                        -<input type='number' min="0" max="100" name="fst" class="text easyui-validatebox"
                                style="width: 60px" required value="${entity.fst}"/>
                    </td>
                </tr>
                <tr>
                    <td align="right">最大充电数：</td>
                    <td><input type='number' min="0" max="100" name="chargeNum" class="text easyui-validatebox"
                               style="width: 60px" required value="${entity.chargeNum}"/>
                    </td>
                    <td align="right">满电电量：</td>
                    <td><input type='number' min="0" max="100" name="fullVolume" class="text easyui-validatebox"
                               style="width: 60px" required value="${entity.fullVolume}"/>
                    </td>
                </tr>
                <tr>
                    <td align="right">开放时间：</td>
                    <td><input type="text" class="text easyui-validatebox" maxlength="40" name="openTime"
                               value="${(entity.openTime)!''}"/></td>
                    <input type="hidden" name="priceSettingId" id="priceSettingId_${pid}" value="${(entity.priceSettingId)!''}">
                    <td align="right">套餐：</td>
                    <td>
                        <input type="text" required="true" id="chargePriceSettingName_${pid}" readonly="readonly"
                               class="text easyui-validatebox" name="priceSettingName"
                               value="${(entity.priceSettingName)!''}" style="width: 172px; height: 28px;"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<script>
    (function () {
        var win = $('#${pid}');
        var jform = win.find('form')
        var form = jform[0];

        win.find('input[name=priceSettingId],input[name=priceSettingName]').click(function () {
            selectPriceSetting();
        });

        function selectPriceSetting() {
            App.dialog.show({
                css: 'width:826px;height:522px;overflow:visible;',
                title: '选择套餐',
                href: "${contextPath}/security/hdw/exchange_price_setting/select_price_setting.htm?agentId=" + win.find('input[name=agentId]').val(),
                windowData: {
                    ok: function (config) {
                        win.find('input[name=priceSettingId]').val(config.exchargerPriceSetting.id);
                        win.find('input[name=priceSettingName]').val(config.exchargerPriceSetting.settingName);
                    }
                },
                event: {
                    onClose: function () {
                    }
                }
            });
        }

        var agent = $('#agent_id_${pid}');
        var strategy = $('#cabinet_strategy_id_${pid}');
        var dividePlan = $('#divite_plan_id_${pid}');
        var powerSupplier = $('#power_supplier_id_${pid}');
        var cabinetSupplier = $('#cabinet_supplier_id_${pid}');

        var snapshot = $.toJSON({
            id: '${entity.id}',
            cabinetName: '${(entity.cabinetName)!''}',
            ip: '${(entity.ip)!''}',
            fot: '${(entity.fot)!''}',
            fst: '${(entity.fst)!''}',
            rpt: '${(entity.rpt)!''}',
            chargeNum: '${(entity.chargeNum)!''}',
            fullVolume: '${(entity.fullVolume)!''}',
            priceSettingId: '${(entity.priceSettingId)!''}',
            pt: '${(entity.pt)!''}',
            activeFlag: <#if (entity.activeFlag)?? && entity.activeFlag == 1>1<#else>0</#if>,
            powerSupplierId: '${(entity.powerSupplierId)!''}',
            cabinetSupplierId: '${(entity.cabinetSupplierId)!''}',
            openTime: '${(entity.openTime)!''}',
            strategyId: '${(entity.strategyId)!''}',
            dividePlanId: '${(entity.dividePlanId)!''}'

        });

        var ok = function () {
            if (!jform.form('validate')) {
                return false;
            }
            var success = true;
            var values = {
                id: '${entity.id}',
                cabinetName: form.cabinetName.value,
                ip: form.ip.value,
                activeFlag: form.activeFlag.checked ? 1 : 0,
                openTime: form.openTime.value,
                fst: form.fst.value,
                fot: form.fot.value,
                pt: form.pt.value,
                priceSettingId: form.priceSettingId.value,
                rpt: form.rpt.value,
                chargeNum: form.chargeNum.value,
                fullVolume: form.fullVolume.value,
                strategyId: strategy.combobox('getValue'),
                dividePlanId: dividePlan.combobox('getValue'),
                powerSupplierId: powerSupplier.combobox('getValue'),
                cabinetSupplierId: cabinetSupplier.combobox('getValue')
            };
            if (snapshot != $.toJSON(values)) {
                $.ajax({
                    cache: false,
                    async: false,
                    type: 'POST',
                    url: '${contextPath}/security/hdw/cabinet/update_basic.htm',
                    dataType: 'json',
                    data: values,
                    success: function (json) {
                    <@app.json_jump/>
                        if (json.success) {
                        } else {
                            $.messager.alert('提示信息', json.message, 'info');
                            success = false;
                        }
                    }
                });
            }

            return success;
        }

        win.data('ok', ok);
    })();
</script>